package com.captjack.wechat.admin.configuration.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;

/**
 * Description description.....
 *
 * @author Jack Sparrow
 * @version 1.0.0
 * @date 2018/4/22 01:34
 * package com.captjack.wechat.admin.configuration.web
 */
public class RequestInterceptorConfiguration {

    /**
     *
     */
    private final HandlerInterceptor blacklistIpInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        //注册自定义拦截器，添加拦截路径和排除拦截路径
        registry.addInterceptor(blacklistIpInterceptor).addPathPatterns("api/path/**").excludePathPatterns("api/path/login");
    }

    @Autowired
    public RequestInterceptorConfiguration(@Qualifier(value = "blacklistIpInterceptor") HandlerInterceptor blacklistIpInterceptor) {
        this.blacklistIpInterceptor = blacklistIpInterceptor;
    }

}
